package com.company.tcpdemo;

import java.io.*;
import java.net.ServerSocket;
import java.net.Socket;

public class ClientThread extends Thread{
    @Override
    public void run() {

        try {
            //服务器ServerSocker
            Socket socket = new Socket("127.0.0.1",9901);

            //向服务器发送消息      socket获取字节流->转换流->缓冲流
            BufferedWriter bw = new BufferedWriter(
                    new OutputStreamWriter(socket.getOutputStream()));

            String sMsg = "你好,asdhakjs";
            System.out.print(sMsg);
            bw.write(sMsg);

            bw.newLine();
            bw.write("eof\n");

            bw.flush();

        } catch (IOException e) {
            e.printStackTrace();
        }

    }
}
